package com.atguigu.yygh.controller;

import com.atguigu.yygh.model.hosp.Schedule;
import com.atguigu.yygh.result.Result;
import com.atguigu.yygh.service.ScheduleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author zr
 * @date 2021/12/14 22:08
 */
@Api(tags = "排班列表")
@RestController
@RequestMapping("/admin/hosp/schedule")
public class ScheduleController {
    @Resource
    private ScheduleService scheduleService;

    /**
     * 根据医院编号 和科室编号 查询排班规则
     */
    @ApiOperation("查询排班规则数据")
    @GetMapping("getScheduleRule/{page}/{limit}/{hosCode}/{depCode}")
    public Result getScheduleRule(
            @PathVariable String depCode, @PathVariable String hosCode, @PathVariable long limit, @PathVariable long page) {
        Map<String, Object> resultMap = scheduleService.getScheduleRule(page, limit, hosCode, depCode);
        return Result.ok(resultMap);
    }

    /**
     * 根据医院编号 和科室编号、工作日期 查询排班详情
     */
    @ApiOperation("查询排班详情")
    @GetMapping("getScheduleDetail/{hosCode}/{depCode}/{workDate}")
    public Result getScheduleDetail(@PathVariable String depCode, @PathVariable String hosCode, @PathVariable String workDate) {
        List<Schedule> scheduleList = scheduleService.getScheduleDetail(hosCode, depCode, workDate);
        return Result.ok(scheduleList);
    }
}
